package com.hinnotek.warehouse.observer

import androidx.lifecycle.Observer
import com.lee.common.utils.PAGE_SIZE
import com.lee.common.vo.PageVO


abstract class ObserverList<T> : Observer<MutableList<T>> {

    override fun onChanged(t: MutableList<T>?) {
        if (t != null) {
            val data = PageVO<T>(t, t.size >= PAGE_SIZE,1)
            onDataChange(data)
        }

    }

    /**
     * 请求数据且数据不为空
     */
    open fun onDataChange(data: PageVO<T>) {

    }


    /**
     * 请求错误
     */
    open fun onError(msg: String?, code: Int) {

    }

}